-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Introduce DSP subsystem #51059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce DSP subsystem #51059
Conversation
|
Note: I didn't implement mul/div yet because I wanted to make sure we're on the same page. |
stephanosio
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not seem to be what we settled on in the chat:
the idea is basically to define "Zephyr DSP API" [...] that is 1-to-1 mapping to CMSIS-DSP.
why do we have to reinvent the API when there is CMSIS-DSP?
We should not be using architecture specific libraries beyond the architecture domain itself.
it is not architecture specific. as I already explained, the library in itself provides pure C implementations of all functions, so it can run on any architectures as is.
let's take a look at "Basic Math" functions for instance:
https://github.com/ARM-software/CMSIS-DSP/blob/main/Include/dsp/basic_math_functions.h
there really is nothing ARM-specific in the "API" functions.
https://github.com/misaleh/CMSIS-DSP-PULPino
https://github.com/Nuclei-Software/NMSIS/tree/master/NMSIS/DSP
examples of other RISC-V vendors forking CMSIS-DSP for their use
just proves my point that this is the most natural way forward.
and we do have a full testsuite for all the CMSIS-DSP functions so verification is going to be less of a hassle.
So, unless you plan to document all these functions and add full comprehensive test suites for all of them, please keep the API identical to that of the CMSIS-DSP.
Also, remember that the functions you have implemented here is just a subset of the "Basic Math" functions -- there are hundreds more in the CMSIS-DSP and deviating from the CMSIS-DSP is not going to be a sustainable approach unless we have someone working on this full time.
|
Updated to use CMSIS-DSP directly via a shimming "core". Note that this will fail to build on some platforms until zephyrproject-rtos/cmsis#20 is merged. |
Please pull the CMSIS-DSP PR here then. |
|
The following west manifest projects have been modified in this Pull Request:
Note: This message is automatically posted and updated by the Manifest GitHub Action. |
I don't know, I'll need to test a few things. Here's a great example of the optimization that can be done with |
|
@ruuddw @SiyuanCheng-CN @teburd @stephanosio Upon further review and consulting with some of our compiler guys I've reached the following conclusions: RE:
|
|
I agree with the __restrict 'risk' and the AGU is obviously not relevant for all architectures/implementations. Therefore the proposal is to add these via macro's that user can configure/define: if not applicable for a certain implementation backend, the preprocessor removes them. |
That seems fair, I guess the tradeoff we're looking at is: Option 1Disallow in-place DSP operations. Which will allow for Option 2Disallow |
|
Nice summary of the options, that's indeed what I think needs to be decided. For a generic API, my vote is to have the stricter semantics. But we probably should get some more inputs on the user side: is there a lot of application code that assumes in-place processing is supported? I'm also not sure if CMSIS-DSP defines this explicitly. |
I posted this last night, I think there's a third option for a Kconfig, but it makes things a bit more complex. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, should add the experimental status to the API overview.rst and a minimal subsys doc that gives a brief overview of the intent here.
https://github.com/zephyrproject-rtos/zephyr/blob/main/doc/develop/api/overview.rst
In my mind this is fine for experimental status, with the expectation that some things may change, potentially in breaking ways still.
stephanosio
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks almost ready, just a minor change for the test names.
include/zephyr/dsp/types.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note to myself (or anyone who might be interested in maintaining this in the future) that CONFIG_FP16 is currently an ARM-specific config and __fp16 is an ARM-specific type.
The CONFIG_FP16 Kconfig should eventually be moved to the same level as CONFIG_FPU and the architecture-agnostic ISO _Float16 type support should be implemented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without knowing the details myself: is there a reason for not using the ISO _Float16 already now then? Is it semantically different from __fp16?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On ARM, the __fp16 type can represent a half-precision floating point value in either IEEE 754-2008 format or the "ARM alternative format" depending on the specified compiler options -- we do not want to take away that capability for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move the tests to tests/subsys/dsp/ as they'll be a part of the Zephyr dsp subsystem. Signed-off-by: Yuval Peress <[email protected]>
|
A few compliance issues look legit |
Introduce an API mirroring the CMSIS-DSP's basicmath. If CMSIS_DSP is enabled, then it will by default be used as a backend. Developers may opt into a custom backend by setting CONFIG_DSP_BACKEND_CMSIS=n. If done, the application must provide `zdsp_backend/dsp.h` and optionally implement the functions in its own .c files. Signed-off-by: Yuval Peress <[email protected]>
Update the relevant tests in basicmath to use the dsp subsystem. Note that f16 is not updated since it's much more architecture specific and did not become a part of zdsp. Signed-off-by: Yuval Peress <[email protected]>
| menuconfig CMSIS_DSP | ||
| bool "CMSIS-DSP Library Support" | ||
| depends on (CPU_CORTEX && NEWLIB_LIBC) || ARCH_POSIX | ||
| depends on NEWLIB_LIBC || ARCH_POSIX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker, but a note, depends on NEWLIBC should be revisited when PICOLIBC becomes the thing
Introduce a shim layer for platforms that do not have official support
in cmsis-dsp via a custom "core" that exposed to the cmsis-dsp library
by adding the "cmsis_compiler.h" file to the include path.